import { User } from "../../../modeal/user.js"
const user = new User()

Page({
  data: {
    adminInfo: [],
    lists: [
      { id: 1, name: '订单详情', icon: '/pages/images/balance_icon.png', path: '/pages/admin/orderList/index/index' },
      { id: 2, name: '骑手管理', icon: '/pages/images/balance_icon.png', path: '/pages/admin/rider/index/index' },
      { id: 3, name: '会员管理', icon: '/pages/images/balance_icon.png', path: '' }
    ],
    perscent1: 0,
    perscent2: 0,
    perscent3: 0,
    //进度条
    percent: 0, //百分比
    size: 100,  //尺寸
    strokeWidth: 4,   //进度环的宽度
    backgroundColor: "#d1dfda",
    color: "#4d7c6c",
    current: 0, //swiper index
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //  获取商户后台数据
    this.getShopInfoAd();
  },

  getShopInfoAd () {
    // 1:今天的数据 2:当月数据 3:所有数据
    let current = this.data.current
    let type = current + 1
    user.getShopInfoAd(type).then(res => {
      let count = res.count
      let count_1 = res.count_1
      let count_2 = res.count_2
      let count_3 = res.count_3
      let perscent1 = count_1 / count * 100
      let perscent2 = count_2 / count * 100
      let perscent3 = count_3 / count * 100
      // console.log(perscent1, perscent2, perscent3);
      if (isNaN(perscent1)) {
        perscent1 = 0;
      }
      if (isNaN(perscent2)) {
        perscent2 = 0;
      }
      if (isNaN(perscent3)) {
        perscent3 = 0;
      }
      this.setData({
        info: res,
        perscent1: perscent1.toFixed(2),
        perscent2: perscent2.toFixed(2),
        perscent3: perscent3.toFixed(2)
      })
    })
  },


  goTo (e) {
    let url = e.currentTarget.dataset.path
    wx.navigateTo({ url });
  },

  bindchange (e) {
    let current = e.detail.current
    this.setData({ current })
    this.getShopInfoAd()

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})